/*
 * Copyright (C) 2010 Young, Fey <fey.young@gmail.com>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

package com.youngfey.chess.engine

import com.youngfey.chess.*
import com.youngfey.util.cli.*
/**
 *
 * @author Young, Fey <fey.young@gmail.com>
 */
abstract class Engine extends CliAgent {
    /**
     * 构建一个引擎
     * @param cmd 用于启动引擎的命令行指令
     */
    def Engine(String cmd) {
        super(cmd)
    }

    /**
     * 判断引擎状态
     * @return 当引擎已启动并处于正常运行状态时返回true
     */
    abstract boolean isReady()

    /**
     * 分析局面。该方法将局面输入引擎进程并启动无限搜索。
     * 在搜索过程中如再次调用该方法，当两次调用的position
     * 相同时不做任何调整，不相同时则重新启动分析过程并丢
     * 弃此前的搜索结果。
     * 启动新的分析任务将清空现有的局面评估值缓存
     * @param position 待分析局面
     */
    abstract void analyze(Position position)

    /**
     * 获取局面估值
     * @return evaluation 此前输入的position当前的评估值，
     * 如评估尚未完成则返回Evaluation.UNCLEAR
     */
    abstract Evaluation getEvaluation()

    /**
     * 停止当前的分析任务
     */
    abstract void stop()
}

